﻿namespace Digitalmes.Domain.Entities.Sys;

/// <summary>
/// 用户信息
/// </summary>
[SugarTable("sys_user")]
public sealed class SysUser : AuditedEntity, ISoftDelete
{
    /// <summary>
    /// 用户账号
    /// </summary>
    [NotNull]
    public string? Username { get; set; }

    /// <summary>
    /// 密码
    /// </summary>
    [NotNull]
    public string? Password { get; set; }

    /// <summary>
    /// 姓名
    /// </summary>
    [NotNull]
    public string? Realname { get; set; }

    /// <summary>
    /// 手机号
    /// </summary>
    public string? Phone { get; set; }

    /// <summary>
    /// 邮件
    /// </summary>
    public string? Email { get; set; }

    /// <summary>
    /// 头像
    /// </summary>
    public string? Avatar { get; set; }

    /// <summary>
    /// 性别
    /// </summary>
    public GenderEnum Gender { get; set; } = GenderEnum.Unknown;

    /// <summary>
    /// 归属的机构 Id
    /// </summary>
    public long? OrgId { get; set; }

    /// <summary>
    /// 归属的机构
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(OrgId))]
    public SysOrg? Org { get; set; }

    /// <summary>
    /// 职位 Id
    /// </summary>
    public long? PosId { get; set; }

    /// <summary>
    /// 职位
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(PosId))]
    public SysPos? Pos { get; set; }

    /// <summary>
    /// 工号
    /// </summary>
    public string? JobNum { get; set; }

    /// <summary>
    /// 职级
    /// </summary>
    public string? PosLevel { get; set; }

    /// <summary>
    /// 入职日期
    /// </summary>
    public DateTime? ServiceDate { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    public string? Remark { get; set; }

    /// <summary>
    /// 启用状态（0->停用，1->启用）
    /// </summary>
    public EnabledStatusEnum Status { get; set; }

    public bool IsDeleted { get; set; }

    /// <summary>
    /// 用户拥有的角色关系集合。
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(SysUserRole.UserId))]
    public List<SysUserRole>? UserRoles { get; set; }
}
